<?php
	session_start();
	function getconnect($database="")
	{
		$con = new mysqli("127.0.0.1","root","1982418781");
		if($con->connect_error)
		{
			die("lost:".$con->connect_error);
		}
		mysqli_select_db($con,$database);
		mysqli_query($con,"set names utf8");
		return $con;
	}
	
	function skip($message='',$url='')
	{
		if(empty($message)&&empty($url))
		{
			return;
		}

		if(empty($message))
		{
			echo "<script>
			window.location.href='$url';
			</script>";
			return;
		}elseif(empty($url))
		{
			echo "<script>alert('".$message."');
			</script>";
			return;
		}
		else
		{
			echo "<script>alert('".$message."');
			window.location.href='$url';
			</script>";
			return;
		}
	}
	function judge()
	{
		if($_SESSION["user"]==null)
		{
			skip("请先登录！","../login.html");
		}
		else {return;}
	}
	
	function getprovince($province){
		if(strstr($province,"北京"))
			return "bj";
		elseif(strstr($province,"天津"))
			return "tj";
		elseif(strstr($province,"上海"))
			return "sh";
		elseif(strstr($province,"重庆"))
			return "cq";
		elseif(strstr($province,"河北"))
			return "hebei";
		elseif(strstr($province,"山西"))
			return "sxi";
		elseif(strstr($province,"辽宁"))
			return "ln";
		elseif(strstr($province,"吉林"))
			return "jl";
		elseif(strstr($province,"黑龙江"))
			return "jl";
		elseif(strstr($province,"江苏"))
			return "jiangsu";
		elseif(strstr($province,"浙江"))
			return "zhejiang";
		elseif(strstr($province,"安徽"))
			return "anhui";
		elseif(strstr($province,"福建"))
			return "anhui";
		elseif(strstr($province,"江西"))
			return "jiangxi";
		elseif(strstr($province,"山东"))
			return "shandong";
		elseif(strstr($province,"河南"))
			return "henan";
		elseif(strstr($province,"湖北"))
			return "hubei";
		elseif(strstr($province,"湖南"))
			return "hunan";
		elseif(strstr($province,"广东"))
			return "guangdong";
		elseif(strstr($province,"海南"))
			return "hainan";
		elseif(strstr($province,"四川"))
			return "sichuan";
		elseif(strstr($province,"贵州"))
			return "guizhou";
		elseif(strstr($province,"云南"))
			return "yunnan";
		elseif(strstr($province,"陕西"))
			return "shanxi";
		elseif(strstr($province,"甘肃"))
			return "gansu";
		elseif(strstr($province,"青海"))
			return "qinghai";
		elseif(strstr($province,"台湾"))
			return "taiwan";
		elseif(strstr($province,"广西"))
			return "guangxi";
		elseif(strstr($province,"内蒙古"))
			return "neimenggu";
		elseif(strstr($province,"西藏"))
			return "xizang";
		elseif(strstr($province,"宁夏"))
			return "ningxia";
		elseif(strstr($province,"新疆"))
			return "xinjiang";
		elseif(strstr($province,"香港"))
			return "xg";
		elseif(strstr($province,"澳门"))
			return "xg";
		else return "bj";
	}
?>
